<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <script src="../../resources/js-test.js"></script>
    <style>
    </style>
  </head>
  <body>
    <svg xmlns="http://www.w3.org/2000/svg"></svg>
    <bar xmlns="http://test/foo"></bar>
    <script>
    description("Test innerHTML in XHTML/XML documents");

    var namespaces = [
        "http://www.w3.org/2000/svg",
        "http://test/foo"
    ];
    var elementnames = [
        "svg",
        "bar"
    ];
    var texts = [
        "&lt;g/>",
        "&lt;body>&lt;/body>"

    ];

    var element, childns;
    function g(ns, elementName, text, appendOrSelect) {
        if (appendOrSelect == "append") {
            element = document.createElementNS(ns, elementName);
            document.body.appendChild(element);
            childns = ns;
        } else {
            element = document.querySelector(elementName);
            childns = element.namespaceURI;
        }
        element.innerHTML = text;
        shouldBeEqualToString("element.firstChild.namespaceURI", childns);
    }

    namespaces.forEach(function(ns) {
        elementnames.forEach(function(elementname) {
            texts.forEach(function(text) {
                g(ns, elementname, text, "append");
                g(ns, elementname, text, "select");
            });
        });
    });
    </script>
  </body>
</html>
